var t = require("../../../../@babel/runtime/helpers/toConsumableArray"), a = getApp();

Page({
    data: {
        active: 0,
        qrCodeFlag: !1,
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        posterImageUrl: "",
        projectList: []
    },
    onLoad: function(t) {},
    changeTags: function(t) {
        console.log(t.detail.index, this.data.active), this.data.active = t.detail.index, 
        this.getListData();
    },
    onReady: function() {},
    onShow: function() {
        this.getListData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    _getMoreData: function() {
        var e = this, i = this;
        if (!(this.data.page >= this.data.total_page)) {
            var o = a.getNetAddresss("plugin.appointment.frontend.appointment-order.get-list");
            this.data.page++, a._postNetWork({
                url: o,
                data: {
                    status: this.data.active,
                    page: this.data.page
                },
                success: function(a) {
                    var o = a.data;
                    if (1 == o.result) {
                        o.data.current_page >= o.data.last_page && i.setData({
                            isLoadMore: !1
                        });
                        var n = e.data.projectList;
                        n.push.apply(n, t(o.data.data)), e.setData({
                            projectList: n
                        });
                    }
                },
                fail: function(t) {
                    console.log(t.msg);
                }
            });
        }
    },
    onShareAppMessage: function() {},
    setQRCodeFlag: function() {
        this.setData({
            qrCodeFlag: !this.data.qrCodeFlag
        });
    },
    createQrc: function(t) {
        var e = this;
        wx.showLoading({
            title: "生成中",
            mask: !0
        });
        var i = t.currentTarget.dataset.item, o = a.getNetAddresss("plugin.appointment.frontend.appointment-order.qr-code-url");
        a._postNetWork({
            url: o,
            data: {
                id: i.id,
                tag: "pro"
            },
            success: function(t) {
                wx.hideLoading();
                var a = t.data;
                if (1 !== a.result) return e.tips(a.msg);
                e.setData({
                    qrCodeFlag: !0,
                    posterImageUrl: a.data.miQrCodeUrl
                });
            },
            fial: function(t) {
                wx.hideLoading();
            }
        });
    },
    toAppointment: function(t) {
        var a = t.currentTarget.dataset.item;
        wx.navigateTo({
            url: "/packageE/appointment/client/make_appointment/make_appointment?id=" + a.id + "&project_id=" + a.project_id
        });
    },
    initData: function() {
        this.data.page = 1, this.data.isLoadMore = !0, this.data.total_page = 0;
    },
    getListData: function() {
        var t = this;
        this.initData();
        var e = a.getNetAddresss("plugin.appointment.frontend.appointment-order.get-list");
        a._postNetWork({
            url: e,
            data: {
                page: 1,
                status: this.data.active
            },
            success: function(a) {
                var e = a.data;
                if (1 !== e.result) return t.tips(e.msg);
                t.data.isLoadMore = !0, t.data.total_page = e.data.last_page, t.data.total_page || (t.data.total_page = 0), 
                t.setData({
                    projectList: e.data.data
                });
            }
        });
    },
    tips: function(t) {
        return wx.showToast({
            title: t,
            icon: "none",
            duration: 2e3
        }), !1;
    },
    goProjectDetails: function(t) {
        var a = t.currentTarget.dataset.id, e = JSON.stringify(wx.getStorageSync("address-point").point);
        wx.navigateTo({
            url: "/packageE/appointment/ProjectDetails/ProjectDetails?project_id=" + a + "&point=" + e
        });
    }
});